﻿var a = 0;
var text;
var selects; //记录玩家的选项
var buynum = 0;
var itemlist = Array(
                                        Array(4009439, 10),
                                        Array(3700182, 100),
                                        Array(2431936, 100),
                                        Array(2433960, 100),
                                        Array(5062024, 4000),//
                                        Array(5062010, 3000),//
                                        Array(5062009, 2000),//超级神奇魔方
	                                Array(5062002, 1000),
                                        Array(5062500, 4000),
					Array(5530268, 4000),
					Array(5530269, 4000),
					Array(2046856, 10000),
					Array(2047978, 5000),
					Array(5064000, 3500),
					Array(5064100, 20000),
					Array(5050000, 100),
					Array(2614002, 80000),
					Array(5072000, 100),
					Array(5073000, 500),
					Array(5074000, 500),
					Array(5076000, 800),
					Array(5390000, 1000),
					Array(5390001, 1000),
					Array(5390002, 1000),
					Array(5390003, 1000),
					Array(5390004, 1000),
					Array(5390005, 2000),
					Array(5390006, 5000),
					Array(5390007, 3000),
					Array(5390008, 3000),
					Array(5079001, 1000),
					Array(5079002, 1000),
					Array(5390010, 5000),
					Array(5390018, 5000),
					Array(5520000, 3000),
					Array(5520001, 5000),
					Array(2610001, 25000),//封印解除卷轴
					Array(2340000, 1500),//祝福卷
					Array(2049323, 4000),//无损强化卷
					Array(2046309, 20000),//周年庆饰品增强卷轴20%
					Array(2046008, 25000),//周年庆单手武器攻击力卷轴50%
					Array(2046009, 25000),//周年庆单手武器魔力卷轴50%
					Array(2046108, 25000), //周年庆双手武器攻击力卷轴50%
					Array(2046109, 25000),//周年庆双手武器魔法力卷轴50%
					Array(2046010, 10000),//周年庆单手武器攻击力卷轴100%
					Array(2046011, 10000),//周年庆单手武器魔法力卷轴100%
					Array(2046110, 10000), //周年庆双手武器攻击力卷轴100%
					Array(2046111, 10000),//周年庆双手武器魔法力卷轴100%
					Array(2046074, 150000),//降龙单手武器攻击力99%
					Array(2046075, 150000),//降龙单手武器魔法力99%
					Array(2046149, 150000),//降龙双手武器攻击力99%
					Array(2049750, 150000),//S级潜能卷80%
					Array(2048306, 3000),//特殊附加潜能附加古卷100%
					Array(2330007, 50000),//高科技穿甲弹
					Array(2070023, 20000), //火焰飞镖
					Array(2049124, 1000), //正向混顿卷
					Array(2049137, 5000),//惊人正义混沌卷40%
					Array(2045212, 50000),//PB双弩枪攻击卷
					Array(2613000, 150000),//星火单手武器攻击力
					Array(2613001, 150000),//星火单手武器魔力卷
					Array(2612010, 150000)
					
				

                                  );
var head = "#fUI/UIWindow2.img/Quest/quest_info/summary_icon/summary#\r\n";

function start() {
    a = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 1)
            a++;
        else
            a--;
        if (a == -1) {
            cm.dispose();
        } else if (a == 0) {
			text = head + "#h0#,你好！在这里可以选择你想要购买的物品,点击图片购买\r\n#b";
			for (var i=0; i<itemlist.length; i++) {
				text += "#L" + i + "##i" + itemlist[i] + "#";
				if (i != 0 && (i+1) % 5 == 0) {
					text += "\r\n";
				}
			}
            cm.sendSimple(text);
        } else if (a == 1) {
			selects = selection;
            cm.sendGetNumber("请输入你请你输入想要购买的数量\r\n\r\n#r - 1个需要" + itemlist[selects][1] + "点卷", 0, 0, 999999);
        } else if (a == 2) {
            buynum = selection;
            cm.sendNext("你想购买" + buynum + "个#r#i" + itemlist[selects][0] + "##k？\r\n你将使用掉" + (buynum * itemlist[selects][1]) + "点卷。");
        } else if (a == 3) {
            if (cm.getChar().getCSPoints(1) >= buynum * itemlist[selects][1]) {
                cm.getChar().modifyCSPoints(1, -buynum * itemlist[selects][1]);
                cm.gainItem(itemlist[selects][0], buynum);
                cm.sendOk("购买成功了！");
                cm.dispose();
            } else {
                cm.sendOk("对不起，你没有足够的点卷。");
                cm.dispose();
            }
        }
    }//mode
}//f
